package com.studyadmin.controller;


import com.studyadmin.entity.StudentLearnimg;
import com.studyadmin.mapper.StudentLearnimgMapper;
import com.studyadmin.service.StudentLearnimgService;
import com.studyadmin.util.JsonUtil;
import org.apache.ibatis.annotations.Arg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lyl
 * @since 2023-04-06
 */
@RestController
@RequestMapping("/studyadmin/student-learnimg")
@CrossOrigin
public class StudentLearnimgController {


    @Autowired
    StudentLearnimgService studentLearnimgService;
    @Autowired
    StudentLearnimgMapper studentLearnimgMapper;

    /**
     * 上传代码截图
     * @param learnImg
     * @param stuNum
     * @param chaId
     * @return
     */
    @GetMapping("/insertStuImgUrl")
    public JsonUtil insertStuImgUrl(@RequestParam(name = "learnImg") String  learnImg,
                                    @RequestParam(name = "stuNum") String  stuNum,
                                    @RequestParam(name = "chaId") String  chaId) {
        StudentLearnimg studentLearnimg = new StudentLearnimg();
        studentLearnimg.setLearnImg(learnImg);
        studentLearnimg.setChaId(Integer.parseInt(chaId));
        studentLearnimg.setStuNum(stuNum);
        studentLearnimg.setAccomplishFlag(0);
        studentLearnimg.setCreateTime(LocalDateTime.now());
        studentLearnimg.setUpdateTime(LocalDateTime.now());
        studentLearnimg.setDelFlag(0);
        int res=studentLearnimgMapper.insert(studentLearnimg);

        JsonUtil jsonUtil = new JsonUtil();
        jsonUtil.setCode(0);
        jsonUtil.setMsg("上传成功");
//        jsonUtil.setData();
        return jsonUtil;

    }

}

